package com.qcu.controller.user;

import com.qcu.annotation.LimitRate;
import com.qcu.annotation.RequireAuthorization;
import com.qcu.entity.Archive;
import com.qcu.entity.Inhabitant;
import com.qcu.service.ArchiveService;
import com.qcu.util.Response;
import com.qcu.vo.ArchiveOfUserVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Name: MyComputer
 * @ClassName ArchiveController
 * @Description:
 * TODO: 进行操作前需要验证居民是否被当前用户所包含
 * @date 2025/2/8 9:32
 */

@RestController("userArchiveController")
@RequestMapping("/user/archive")
public class ArchiveController {

    @Resource
    private ArchiveService archiveService;

    /**
     * 用户根据id查询居民档案
     * @param id
     * @return
     */
    @GetMapping("/get/{id}")
    @LimitRate(key = "getArchiveById",permitsPerSecond = 2,expire = 10,msg = "八嘎雅鹿，你滴点那么快滴干什么滴干活...")
    @RequireAuthorization({"USER"})
    public Response get(@PathVariable Integer id){
        Archive archive = archiveService.getById(id);
        return Response.success(archive);
    }
    @GetMapping("/get/archiveOfUser/{username}")
    @LimitRate(key = "getUserArchiveOfUserName",permitsPerSecond = 2,expire = 10,msg = "八嘎雅鹿，你滴点那么快滴干什么滴干活...")
    @RequireAuthorization({"USER"})
    public Response getArchiveOfUser(@PathVariable String username){
        List<ArchiveOfUserVO> inform = archiveService.getArchiveOfUser(username);
        return Response.success(inform);
    }

}
